package org.yu.register.mobeffect;

import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;

import javax.annotation.Nonnull;

public class InvincibleEffect extends MobEffect {
    public InvincibleEffect(MobEffectCategory category, int p_19452_) {
        super(category, p_19452_);
    }

    @Override
    public boolean isDurationEffectTick(int pDuration, int pAmplifier) {
        var level= Mth.clamp(pAmplifier,0,9);
        return pDuration%((10-level)*20)==0;
    }

    @Override
    public boolean isInstantenous() {
        return false;
    }

    @Override
    public void applyEffectTick(@Nonnull LivingEntity pLivingEntity, int pAmplifier) {
        pLivingEntity.invulnerableTime=25;
    }
}
